"""
报告生成配置管理
"""
import os
from typing import Dict, Any

class ReportConfig:
    """报告生成配置类"""
    
    def __init__(self):
        # API配置
        self.api_key = os.getenv('SILICONFLOW_API_KEY') or os.getenv('OPENAI_API_KEY')
        self.api_url = "https://api.siliconflow.cn/v1/chat/completions"
        self.model = "Qwen/QwQ-32B"
        
        # LLM参数配置
        self.llm_config = {
            "max_tokens": 2000,
            "temperature": 0.7,
            "top_p": 0.7,
            "top_k": 50,
            "frequency_penalty": 0.5,
            "timeout": 60
        }
        
        # 代理配置
        self.agent_config = {
            "planner": {
                "max_tokens": 2000,
                "temperature": 0.3,
                "retry_count": 3
            },
            "structure": {
                "max_tokens": 1500,
                "temperature": 0.2,
                "retry_count": 2
            },
            "writer": {
                "max_tokens": 3000,
                "temperature": 0.5,
                "retry_count": 3
            },
            "quality": {
                "max_tokens": 1000,
                "temperature": 0.1,
                "retry_count": 2
            }
        }
        
        # 报告配置
        self.report_config = {
            "min_sections": 3,
            "max_sections": 8,
            "min_words_per_section": 200,
            "max_words_per_section": 1000,
            "quality_threshold": 7.0
        }
    
    def get_agent_config(self, agent_name: str) -> Dict[str, Any]:
        """获取特定代理的配置"""
        base_config = self.llm_config.copy()
        agent_specific = self.agent_config.get(agent_name, {})
        base_config.update(agent_specific)
        return base_config
    
    def validate_config(self) -> bool:
        """验证配置是否有效"""
        if not self.api_key:
            return False
        return True

# 全局配置实例
config = ReportConfig() 